const Params = imports.misc.params;
const MENU_POPUP_TIMEOUT = 600;
+const SCROLL_TIME = 0.1;
function AlphabeticalView() {
this._init();
let appIcon = new AppWellIcon(this._appSystem.get_app(appInfo.get_id()));
this._grid.addItem(appIcon.actor);
+ appIcon.actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
appIcon._appInfo = appInfo;
if (this._filterApp && !this._filterApp(appInfo))
this._apps.push(appIcon);
},
+ _ensureIconVisible: function(icon) {
+ let adjustment = this.actor.vscroll.adjustment;
+ let [value, lower, upper, stepIncrement, pageIncrement, pageSize] = adjustment.get_values();
+
+ let offset = 0;
+ let vfade = this.actor.get_effect("vfade");
+ if (vfade)
+ offset = vfade.fade_offset;
+
+ if (icon.y < value + offset)
+ value = Math.max(0, icon.y - offset);
+ else if (icon.y + icon.height > value + pageSize - offset)
+ value = Math.min(upper, icon.y + icon.height + offset - pageSize);
+ else
+ return;
+
+ Tweener.addTween(adjustment,
+ { value: value,
+ time: SCROLL_TIME,
+ transition: 'easeOutQuad' });
+ },
+
setFilter: function(filter) {
this._filterApp = filter;
for (let i = 0; i < this._apps.length; i++)
}));
this._sections = [];
+
+ // We need a dummy actor to catch the keyboard focus if the
+ // user Ctrl-Alt-Tabs here before the deferred work creates
+ // our real contents
+ this._focusDummy = new St.Bin({ can_focus: true });
+ this.actor.add(this._focusDummy);
},
_scrollFilter: function(actor, event) {
_addFilter: function(name, num) {
let button = new St.Button({ label: GLib.markup_escape_text (name, -1),
style_class: 'app-filter',
- x_align: St.Align.START });
+ x_align: St.Align.START,
+ can_focus: true });
this._filters.add(button, { expand: true, x_fill: true, y_fill: false });
button.connect('clicked', Lang.bind(this, function() {
this._selectCategory(num);
this._addFilter(sections[i], i);
this._selectCategory(-1);
+
+ if (this._focusDummy) {
+ let focused = this._focusDummy.has_key_focus();
+ this._focusDummy.destroy();
+ this._focusDummy = null;
+ if (focused)
+ this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
+ }
}
};
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
+const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Signals = imports.signals;
const SearchDisplay = imports.ui.searchDisplay;
const Tweener = imports.ui.tweener;
-function BaseTab(titleActor, pageActor) {
- this._init(titleActor, pageActor);
+function BaseTab(titleActor, pageActor, name, a11yIcon) {
+ this._init(titleActor, pageActor, name, a11yIcon);
}
BaseTab.prototype = {
- _init: function(titleActor, pageActor) {
+ _init: function(titleActor, pageActor, name, a11yIcon) {
this.title = titleActor;
this.page = new St.Bin({ child: pageActor,
x_align: St.Align.START,
y_fill: true,
style_class: 'view-tab-page' });
+ if (this.title.can_focus) {
+ Main.ctrlAltTabManager.addGroup(this.title, name, a11yIcon);
+ } else {
+ Main.ctrlAltTabManager.addGroup(this.page, name, a11yIcon,
+ { proxy: this.title,
+ focusCallback: Lang.bind(this, this._a11yFocus) });
+ }
+
this.visible = false;
},
});
},
+ _a11yFocus: function() {
+ this._activate();
+ this.page.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
+ },
+
_activate: function() {
this.emit('activated');
}
Signals.addSignalMethods(BaseTab.prototype);
-function ViewTab(label, pageActor) {
- this._init(label, pageActor);
+function ViewTab(label, pageActor, a11yIcon) {
+ this._init(label, pageActor, a11yIcon);
}
ViewTab.prototype = {
__proto__: BaseTab.prototype,
- _init: function(label, pageActor) {
+ _init: function(label, pageActor, a11yIcon) {
let titleActor = new St.Button({ label: label,
style_class: 'view-tab-title' });
titleActor.connect('clicked', Lang.bind(this, this._activate));
- BaseTab.prototype._init.call(this, titleActor, pageActor);
+ BaseTab.prototype._init.call(this, titleActor, pageActor, label, a11yIcon);
}
};
active; it should not exceed ~30
characters. */
hint_text: _("Type to search..."),
- track_hover: true });
+ track_hover: true,
+ can_focus: true });
this._text = this._entry.clutter_text;
this._text.connect('key-press-event', Lang.bind(this, this._onKeyPress));
this._searchResults = new SearchDisplay.SearchResults(this._searchSystem, this._openSearchSystem);
BaseTab.prototype._init.call(this,
this._entry,
- this._searchResults.actor);
+ this._searchResults.actor,
+ _("Search"),
+ 'edit-find');
this._text.connect('text-changed', Lang.bind(this, this._onTextChanged));
this._text.connect('activate', Lang.bind(this, function (se) {
}));
},
- addViewTab: function(title, pageActor) {
- let viewTab = new ViewTab(title, pageActor);
+ addViewTab: function(title, pageActor, a11yIcon) {
+ let viewTab = new ViewTab(title, pageActor, a11yIcon);
this._tabs.push(viewTab);
this._tabBox.add(viewTab.title);
this._addTab(viewTab);